﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>编辑资料</title>
    <link rel="stylesheet" href="css/amazeui.css">
    <link href="css/amazeui.datetimepicker.css" rel="stylesheet" />
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
    <style>
        * {
            padding: 0;
            border: 0;
            margin: 0;
        }

        .veads_01 {
            height: 6rem;
            width: 100%;
            overflow: hidden;
            padding: 0 3%;
            line-height: 6rem;
            z-index: 999999999;
            position: relative;
            background: #fff;
            border-bottom: 1px solid #d3d3d3;
        }

        .veads1_i1 {
            display: block;
            float: left;
            margin-top: 6%;
            width: 2.5%;
        }

        .veads1_s1 {
            display: block;
            text-align: center;
            font-size: 1.8rem;
        }

        .ordts_01 {
            width: 100%;
            overflow: hidden;
            padding: 0 3%;
        }

        .orde_02 {
            background: #efefef;
            width: 100%;
            padding: 1% 0;
        }

        .orde_03 {
            position: fixed;
            bottom: 0;
            width: 100%;
        }

        /*一下为临时*/
        .veas_10 {
            background: rgba(0,0,0,0.2);
            position: fixed;
            width: 100%;
            height: 100%;
            top: 0;
            z-index: 100000000;
        }

        .veas10_d1 {
            background: #fff;
            width: 100%;
            height: 75%;
            position: absolute;
            bottom: 0;
        }

        .veas10_d2 {
            width: 100%;
            padding: 3% 5%;
            overflow: hidden;
            border-bottom: 1px solid #d3d3d3;
        }

        .veas10_i1 {
            display: block;
            float: left;
            width: 3%;
            margin-top: 0.6%;
            margin-right: 10%;
        }

        .veas10_d3 {
            overflow: hidden;
            float: left;
            width: 25%;
            margin-right: 3%;
        }

        .veas10_s1 {
            height: 2.4rem;
            width: 50%;
            background: #efefef;
            border-radius: 3px;
            display: block;
            float: left;
            margin-right: 10%;
        }

        .veas10_s2 {
            display: block;
            float: left;
            width: 37%;
            margin-top: 4%;
            font-size: 1.2rem;
        }

        .veas10_d4 {
            overflow-y: auto;
            height: 50%;
            width: 100%;
        }

        .veas10_d5 {
            overflow: hidden;
            margin-top: 5%;
            padding-left: 15%;
        }

        .veas10_s3 {
            font-size: 1.2rem;
            display: block;
            margin-right: 2.6%;
            margin-bottom: 10%;
            margin-top: 11%;
            text-align: center;
        }

        .veas10_d6 {
            width: 100%;
            padding: 0 2%;
            overflow: hidden;
        }

        .veas10_s4 {
            font-size: 1.1rem;
            display: block;
            margin-right: 3.3%;
            width: 100%;
            /*margin-bottom: 0.8rem;*/
            height: 2.1rem;
            margin-bottom: 11.7%;
        }

        .veas10_s5 {
            display: block;
            height: 1.8rem;
            /*width: 9%;*/
            background: #efefef;
            border-radius: 5px;
            font-size: 1.1rem;
            text-align: center;
            color: #efefef;
            line-height: 1.8rem;
            float: left;
            margin-right: 1.8%;
            margin-bottom: 2%;
        }

        .veas10_d7 {
            padding: 3% 7%;
            width: 100%;
            margin-top: 1%;
        }

        .veas10_s6 {
            font-size: 2rem;
            display: block;
            margin-bottom: 3%;
        }

        .veas10_d8 {
            width: 10.5rem;
            border: 1px solid #23c788;
            overflow: hidden;
            padding-bottom: 0.3rem;
            float: left;
        }

        .veas10_s7 {
            display: block;
            font-size: 1.4rem;
            color: #727272;
            padding-left: 10%;
        }

        .veas10_s8 {
            display: block;
            color: #ff7676;
            font-size: 1.22rem;
            padding-left: 6%;
        }

        .veas10_i2 {
            display: block;
            float: right;
            margin-top: -20%;
            margin-right: 3%;
            width: 8%;
        }

        .veas10_d9 {
            overflow: hidden;
        }

        .veas10_d10 {
            overflow-x: auto;
        }

        .veas10_but {
            font-size: 1.8rem;
            text-align: center;
            color: #fff;
            background: #dadada;
            position: absolute;
            bottom: 0;
            border-radius: inherit;
            width: 100%;
            padding: 4% 0;
        }

        .veas10_s5_other {
            color: #fff;
            background: #23c788;
        }

        .other_veas10_d {
            height: 1.8rem;
            width: 90%;
            overflow: hidden;
            margin-right: 1.8%;
            margin-bottom: 9%;
            position: relative;
        }

        .other_veas10_s {
            height: 1.8rem;
            border-radius: 5px;
            font-size: 1.1rem;
            text-align: center;
            color: #efefef;
            line-height: 1.8rem;
            background: #23c788;
            position: absolute;
            display: none;
        }

        .veas10_but_other {
            background: #23c788;
        }

        .veas10_d11 {
            margin-bottom: 11.7%;
            border: 1px solid #efefef;
            background: #efefef;
            border-radius: 5px;
            height: 2.1rem;
        }

        .am-g_other {
            background: #23c788;
            color: #fff;
        }

        .vdts_s {
            border-radius: 5px;
            background: #efefef;
        }

        .vdts {
            width: 3.8rem;
        }

        .vedtls {
            background: #23c788;
            color: #fff;
            text-align: center;
            font-size: 0.8rem;
        }

        .veas10_other {
            width: 100%;
            height: 25%;
            position: absolute;
            top: 0;
        }
    </style>
</head>
<body>
    <div id="vult" v-cloak>
        <header data-am-widget="header" class="am-header am-header-default" style="background-color: #FFFFFF; border-bottom: 1px solid rgb(211, 211, 211);">
            <div class="am-header-left am-header-nav" onclick="goBack()">
                <a href="javascript:" class="">
                    <img class="am-header-icon-custom" src="images/veas07.png" alt="" />
                </a>
            </div>
            <h4 class="am-header-title" style=" color: black;">编辑资料</h4>
            <div class="am-header-right am-header-nav"><a href="/Wap/Index.html" class="am-header-icon am-icon-home" style="color: #A9A9A9; "></a></div>
        </header>
        <div class="ordts_01">
            <ul class="am-list" style="margin-bottom: 0">

                <li style="overflow: hidden;border-top: none;padding: 3% 0;font-weight: 500">
                    <span style="float:left;padding-top:10px;">头像</span>
                    <span class="am-icon am-icon-angle-right" style="float: right; padding-top: 10px; "></span>
                    <span style="float:right; padding-right:10px;">
                        <label>
                            <input type="file" id="doc-ipt-file-1" onchange="upload()" multiple name="file" class="am-btn am-btn-default am-btn-sm" style="display:none">
                            <img v-bind:src="faceImg!= null ? faceImg : 'images/nouserfaceimg.png'" style="width:50px;height:50px;" />
                        </label>
                    </span>
                </li>

            </ul>
        </div>
        <div class="orde_02"></div>
        <div class="ordts_01">
            <ul class="am-list m-widget-list" style="margin-bottom: 0">

                <li style="overflow: hidden;padding: 3% 0;font-weight: 500">
                    <span style="float:left;">姓名</span><span class="am-icon am-icon-angle-right" style="float:right"></span><input style="float:right;text-align:right;padding-right:10px;"  placeholder="请输入姓名" v-model="Name">
                </li>
                <li style="overflow: hidden;padding: 3% 0;font-weight: 500">
                    <span style="float:left;">身份证</span><span class="am-icon am-icon-angle-right" style="float:right"></span><input style="float:right;text-align:right;padding-right:10px;" placeholder="请输入身份证" v-model="Idcard">
                </li>
                <li style="overflow: hidden;padding: 3% 0;font-weight: 500">
                    <span style="float:left;">性别</span><span class="am-icon am-icon-angle-right" style="float:right"></span>
                    <select style="float: right; text-align: right; padding-right: 10px; background-color: #FFFFFF; appearance: none; -moz-appearance: none; -webkit-appearance: none;" v-model="Sex" placeholder="请选择性别">
                        <option value="0">请选择</option>
                        <option value="1">男</option>
                        <option value="2">女</option>
                    </select>
                </li>
            </ul>
        </div>

        <div class="orde_03">
            <!--<button type="button" class="am-btn am-btn-default" v-on:click="cancel" style="float:left;width: 49.9%;border: none;background: #cccccc;color: #fff;height: 5.5rem;">取消</button>-->
            <button type="button" class="am-btn am-btn-default" v-on:click="edit" style="width: 100%; border: none;background: #23c788;color: #fff;height: 5.5rem;">修改</button>
        </div>

    </div>
</body>
</html>
<script src="js/vue.js"></script>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/common.js"></script>
<script src="http://file.jiaoxin-tech.cn/help/js/upyun.js"></script>
<script>
    var page = new Vue({
        el: '#vult',
        data: {
            userinfo: [],//用户信息
            faceImg: "",
            Sex: "0",
            Idcard: "",
            Name: "",
        },
        methods: {
            getInfo: function () {
                var that = this;
                $.ajax({
                    type: 'POST',
                    url: apiUrl + '/Api/Mine/GetMyInfo',
                    success: function (data) {
                        //console.log(data.data);
                        if (data.errcode == 0) {
                            that.userinfo = data.data;
                            console.log(data.data);
                            that.faceImg = data.data.headImg;
                            that.Sex = data.data.Sex;
                            that.Idcard = data.data.Idcard;
                            that.Name = data.data.Name;

                        } else {
                            alert(data.errmsg);
                        }
                    },
                    //error: function () {
                    //    alert("服务器加载异常");
                    //}
                })
            },
            edit: function () {
                var that = this;
                $.ajax({
                    url: thisUrl + "/Api/Mine/EditUser",
                    data: { Name: that.Name, Idcard: that.Idcard, Sex: that.Sex, faceImg: that.faceImg },
                    type: "POST",
                    success: function (data) {
                        if (data.errcode == 0) {
                            alert("修改成功", function () {
                                location.replace('/Wap/Index.html#/userCenter');
                            });
                        } else {
                            alert(data.errmsg);
                        }
                    },
                })
            },
        }
    });
    $(function () {
        page.getInfo();
    })
</script>

<script type="text/javascript">
    var filebase = "http://file.jiaoxin-tech.cn";
    var upyun = new Upyun({
        bucket: 'topman-upyun',//'topman-upyun',
        operator: 'admin',
        getSignatureUrl: 'https://xcx.egaopa.com/Api/upyun/index',
        opts: {
            'notify-url': 'http://feiyu.test.jiaoxin-tech.cn/Api/test/upyun',
            //'x-gmkerl-thumb':'/quality/75',//压缩,只能上传图片类型
            //'content-secret':'zhangsan',//文件密钥，用于保护文件，防止文件被直接访问
            //'allow-file-type':'jpg,jpeg,png',//允许上传的文件扩展名，以 , 分隔
            //'content-length-range':'',//文件大小限制，格式：min,max，单位：字节 如 102400,1024000，表示允许上传 100Kb～1Mb 的文件
            //'ext-param':'',//自定义参数,回调时带回
            //'b64encoded':'on',//base64解码
        }
    })


    function upload() {
        if (document.getElementById("doc-ipt-file-1").files.length > 0) {
            for (var n = 0; n < document.getElementById("doc-ipt-file-1").files.length; n++) {
                upyun.upload({
                    localPath: document.getElementById("doc-ipt-file-1").files[n],
                    remotePath: '/feiyu/{filemd5}{.suffix}',
                    success: function (res) {
                        //document.getElementById("fileurl").setAttribute('href', filebase + res.url);
                        //document.getElementById("fileurl").innerHTML = filebase + res.url;
                        alert('上传成功');
                        page.faceImg = filebase + res.url;
                        console.log('上传成功:', res)
                    }, error: function (err) {
                        alert("上传失败:" + err.message);
                    }, complete: function (xhr) {
                        console.log("上传操作结束:", xhr);
                    }, progress: function (e) {
                        //document.getElementById("progress").innerHTML = parseInt(((e.loaded / e.total) || 0) * 100) + "%";
                        //document.getElementById("number").innerHTML = e.total < 1024 * 1024 ? ((e.loaded / 1024).toFixed(2) + "k/" + (e.total / 1024).toFixed(2) + "k") : ((e.loaded / (1024 * 1024)).toFixed(2) + "M/" + (e.total / (1024 * 1024)).toFixed(2) + "M");
                    }
                })
            }
        }
    }
</script>
